using GameBasic;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace VCity
{
    public class FlowHotelAnim : MonoBehaviour
    {
        public List<Animator> animators;

        public TimeCounter timer = new TimeCounter(15);
        bool idle;

        private void Awake()
        {
            idle = true;
        }

        // Update is called once per frame
        void Update()
        {
            if (idle)
            {
                if (timer.UpdateRestart())
                {
                    // next 
                    int index = Random.Range(0, 3);
                    Play($"Anim{index}");
                    idle = false;
                }
            }
            else
            {
                // end?
                var state = animators[0].GetCurrentAnimatorStateInfo(0);
                if (state.normalizedTime >= 1)
                {
                    int index = Random.Range(0, 2);
                    Play($"Idle{index}");
                    idle = true;
                }
            }
        }

        void Play(string anim)
        {
            for (int i = 0, length = animators.Count; i < length; i++)
            {
                animators[i].Play(anim);
            }
        }
    }
}